
#include "util.h"
#include "log.h"

namespace STLF{

	//define some global object
	int logLevel = 0;
	Nullstream nullstream;
	int Logstream::doneSetup = 1718;
	bool __destroyingStatics = false;

	//end of define some global object

	class myevent_imp
	{
		boost::condition_variable_any _cond;
		boost::mutex _mutex;

		myevent_imp(const myevent &e);
		myevent_imp & operator=(const myevent &e);

	public:
		myevent_imp()
		{

		}
		~myevent_imp()
		{

		}

		void waiting()
		{
			boost::unique_lock<boost::mutex> lock(_mutex);
			_cond.wait(lock);
		}

		void notify_one()
		{
			_cond.notify_one();
		}

		void notify_all()
		{
			_cond.notify_all();
		}

	};

	myevent::myevent():_pmyevent_imp(new myevent_imp){}
	myevent::~myevent(){delete _pmyevent_imp;}

	void myevent::waiting()
	{
		_pmyevent_imp->waiting();
	}

	void myevent::notify_one()
	{
		_pmyevent_imp->notify_one();
	}

	void myevent::notify_all()
	{
		_pmyevent_imp->notify_all();
	}

	using boost::posix_time::microsec;
	using boost::posix_time::millisec;

	void sleep(unsigned int sleep_time)
	{
		boost::this_thread::sleep(millisec(sleep_time));
	}	
	
}